require(estimatr)
require(cregg)
attribute.name <- c("gender", "party", "age", "education", "occupation", 
                    "hometown", "experience", "dynasty")
level.wording <- list(c("男性", "女性"), 
                      c("無所属", "自由民主党所属", "立憲民主党所属", "公明党所属", "日本維新の会所属", "日本共産党所属"), 
                      c("42歳", "52歳", "59歳", "67歳"), 
                      c("高校卒", "専門学校卒", "私立大学卒", "地方国立大学卒", "東京大学卒", "大学院卒"), 
                      c("前の職業は会社員", "前の職業は会社役員", "前の職業は公務員", "前の職業は国会議員秘書", "前の職業はタレント", "前の職業は地方政治家"), 
                      c("X外出身", "X出身"), 
                      c("国会議員経験なし", "これまで国会議員を6年経験", "これまで国会議員を12年以上経験"), 
                      c("親の政治家経験はなし", "親は元地方政治家", "親は元国会議員", "親は元大臣"))
level.label <- list(c("Male", "Female"), 
                    c("Independent", "LDP", "CDP", "Komeito", "JIP", "JCP"), 
                    c("42", "52", "59", "67"), 
                    c("High school", "Vocational college", "Private university", 
                      "Local public university", "University of Tokyo", "Graduate school"), 
                    c("Buniness employee", "Business executive", 
                      "Government employee", "Secretary", "Celebrity", 
                      "Local politician 1"), 
                    c("Outside", "Inside"), 
                    c("No experience", "6 years in office", "12+ years in office"), 
                    c("None", "Local politician 2", "Diet member", "Cabinet minister"))

#### loading data ####
## respondent-level data
demand.resp.data <- read.csv("demand_side_data.csv")
N <- nrow(demand.resp.data)
N

demand.resp.data$man <- (demand.resp.data$R.gender == 1) * 1
demand.resp.data$woman <- (demand.resp.data$R.gender == 2) * 1
demand.resp.data$mid.edu <- (demand.resp.data$R.education > 2 & 
                               demand.resp.data$R.education < 6) * 1
demand.resp.data$high.edu <- (demand.resp.data$R.education > 5) * 1
demand.resp.data$LDP.support <- (demand.resp.data$partisanship == 1) * 1
demand.resp.data$independent <- (demand.resp.data$partisanship > 9) * 1
demand.resp.data$importance.HOR <- ifelse(demand.resp.data$election_1 == "HOR", 
                                          demand.resp.data$importance_1, 
                                          ifelse(demand.resp.data$election_2 == "HOR", 
                                                 demand.resp.data$importance_2, 
                                                 demand.resp.data$importance_3))
demand.resp.data$importance.HOC <- ifelse(demand.resp.data$election_1 == "HOC", 
                                          demand.resp.data$importance_1, 
                                          ifelse(demand.resp.data$election_2 == "HOC", 
                                                 demand.resp.data$importance_2, 
                                                 demand.resp.data$importance_3))
demand.resp.data$importance.local <- ifelse(demand.resp.data$election_1 == "local", 
                                            demand.resp.data$importance_1, 
                                            ifelse(demand.resp.data$election_2 == "local", 
                                                   demand.resp.data$importance_2, 
                                                   demand.resp.data$importance_3))
demand.resp.data$prioritize.HOR <- (demand.resp.data$importance.HOR - 
                                      demand.resp.data$importance.HOC > 0) * 1

## create variable representing respondents * profile
# record the place of each attribute in the conjoint table for each respondent
attribute <- matrix(NA, N, 8)
for (i in 1:N) {
  count <- 1
  for (j in seq(34, 48, 2)) {
    attribute[i, count] <- match(demand.resp.data[i, j], attribute.name)
    count <- count + 1
  }
}

# record the attribute levels of 20 hypothetical profiles for each respondent
position <- array(NA, c(N, 8, 20))
for (i in 1:N) {
  for (j in 1:20) {
    count <- 1
    for (k in seq(19 + 16 * j, 33 + 16 * j, 2)) {
      position[i, count, j] <- match(demand.resp.data[i, k], level.wording[[attribute[i, count]]])
      count <- count + 1
    }
  }
}

# arrange the array of respondent * attribute * levels by attributes
profile <- array(NA, c(N, 8, 20))
for (i in 1:N) {
  for (j in 1:8) {
    for (k in 1:20) {
      profile[i, j, k] <- position[i, which(attribute[i, ] == j), k]
    }
  }
}

# record how each respondent answered
rating <- matrix(NA, N, 20)
for (i in 1:N) {
  for (j in 1:10) {
    rating[i, j] <- eval(parse(text = paste0("demand.resp.data$Q", j, "_HOR[i]")))
  }
  for (j in 1:10) {
    rating[i, j + 10] <- eval(parse(text = paste0("demand.resp.data$Q", j, "_HOC[i]")))
  }
}

# task number
task <- c()
for (i in 1:N) {
  if (demand.resp.data$HOR_first[i] == 1) {
    task <- c(task, 1:20)
  } else {
    task <- c(task, c(11:20, 1:10))
  }
}

# create dataset whose unit of observation is respondent * profile 
demand.data <- data.frame(rid = rep(1:N, each = 20), 
                          task = task, 
                          rating = as.vector(t(rating)), 
                          gender = factor(as.vector(t(profile[, 1, ])), levels = 1:2, 
                                          labels = level.label[[1]]), 
                          party = factor(as.vector(t(profile[, 2, ])), levels = 1:6, 
                                         labels = level.label[[2]]), 
                          age = factor(as.vector(t(profile[, 3, ])), levels = 1:4, 
                                       labels = level.label[[3]]), 
                          education = factor(as.vector(t(profile[, 4, ])), levels = 1:6, 
                                             labels = level.label[[4]]), 
                          occupation = factor(as.vector(t(profile[, 5, ])), levels = 1:6, 
                                              labels = level.label[[5]]), 
                          hometown = factor(as.vector(t(profile[, 6, ])), levels = 1:2, 
                                            labels = level.label[[6]]), 
                          experience = factor(as.vector(t(profile[, 7, ])), levels = 1:3, 
                                              labels = level.label[[7]]), 
                          dynasty = factor(as.vector(t(profile[, 8, ])), levels = 1:4, 
                                           labels = level.label[[8]]), 
                          HOC = rep(c(rep(0, 10), rep(1, 10)), times = N), 
                          priming = rep(demand.resp.data$priming, each = 20), 
                          R.gender = rep(demand.resp.data$R.gender, each = 20), 
                          prioritize.HOR = rep(demand.resp.data$prioritize.HOR, each = 20))

#### census distribution ####
census.age.gender <- read.csv("census_age_gender.csv")
census.prefecture.age <- read.csv("census_prefecture_age.csv")

## Table A.3 (gender)
# survey
round(prop.table(table(demand.resp.data$R.gender)), 3)
# census
round(prop.table(colSums(census.age.gender[, c("male", "female")])), 3)

## Table A.3 (age)
# survey
round(prop.table(c(sum(demand.resp.data$R.age < 30), 
                   sum(demand.resp.data$R.age >= 30 & demand.resp.data$R.age < 40), 
                   sum(demand.resp.data$R.age >= 40 & demand.resp.data$R.age < 50), 
                   sum(demand.resp.data$R.age >= 50 & demand.resp.data$R.age < 60), 
                   sum(demand.resp.data$R.age >= 60 & demand.resp.data$R.age < 70), 
                   sum(demand.resp.data$R.age >= 70))), 3)
# census
round(prop.table(c(sum(census.age.gender[census.age.gender$age >= 18 & 
                                           census.age.gender$age < 30, -1]), 
                   sum(census.age.gender[census.age.gender$age >= 30 & 
                                           census.age.gender$age < 40, -1]), 
                   sum(census.age.gender[census.age.gender$age >= 40 & 
                                           census.age.gender$age < 50, -1]), 
                   sum(census.age.gender[census.age.gender$age >= 50 & 
                                           census.age.gender$age < 60, -1]), 
                   sum(census.age.gender[census.age.gender$age >= 60 & 
                                           census.age.gender$age < 70, -1]), 
                   sum(census.age.gender[census.age.gender$age >= 70, -1]))), 3)

## Table A.3 (region of residence)
# survey
round(prop.table(c(sum(demand.resp.data$prefecture == 1), 
                   sum(demand.resp.data$prefecture >= 2 & 
                         demand.resp.data$prefecture < 8), 
                   sum(demand.resp.data$prefecture >= 8 & 
                         demand.resp.data$prefecture < 15), 
                   sum(demand.resp.data$prefecture >= 15 & 
                         demand.resp.data$prefecture < 24), 
                   sum(demand.resp.data$prefecture >= 24 & 
                         demand.resp.data$prefecture < 31), 
                   sum(demand.resp.data$prefecture >= 31 & 
                         demand.resp.data$prefecture < 36), 
                   sum(demand.resp.data$prefecture >= 36 & 
                         demand.resp.data$prefecture < 40), 
                   sum(demand.resp.data$prefecture >= 40))), 3)
# census
round(prop.table(c(sum(census.prefecture.age[census.prefecture.age$prefecture == 
                                               "Hokkaido", -1]), 
                   sum(census.prefecture.age[census.prefecture.age$prefecture %in%  
                                               c("Aomori", "Iwate", "Miyagi", 
                                                 "Akita", "Yamagata", "Fukushima"), -1]), 
                   sum(census.prefecture.age[census.prefecture.age$prefecture %in% 
                                               c("Ibaraki", "Tochigi", "Gunma", 
                                                 "Saitama", "Chiba", "Tokyo", 
                                                 "Kanagawa"), -1]), 
                   sum(census.prefecture.age[census.prefecture.age$prefecture %in% 
                                               c("Niigata", "Toyama", "Ishikawa", 
                                                 "Fukui", "Yamanashi", "Nagano", 
                                                 "Gifu", "Shizuoka", "Aichi"), -1]), 
                   sum(census.prefecture.age[census.prefecture.age$prefecture %in% 
                                               c("Mie", "Shiga", "Kyoto", 
                                                 "Osaka", "Hyogo", "Nara", 
                                                 "Wakayama"), -1]), 
                   sum(census.prefecture.age[census.prefecture.age$prefecture %in% 
                                               c("Tottori", "Shimane", "Okayama", 
                                                 "Hiroshima", "Yamaguchi"), -1]), 
                   sum(census.prefecture.age[census.prefecture.age$prefecture %in% 
                                               c("Tokushima", "Kagawa", "Ehime", 
                                                 "Kochi"), -1]), 
                   sum(census.prefecture.age[census.prefecture.age$prefecture %in% 
                                               c("Fukuoka", "Saga", "Nagasaki", 
                                                 "Kumamoto", "Oita", "Miyazaki", 
                                                 "Kagoshima", "Okinawa"), -1]))), 3)

#### equivalence tests of pretreatment variable ####
equivarence.test <- function(data.tested,  # data frame containing variables
                             variable,  # variable to be tested
                             treatment,  # treatment variable
                             epsilon  # equivalence limits
) {
  treatment.vec <- data.tested[, treatment]
  treatment.group <- data.tested[treatment.vec == 1, ]
  control.group <- data.tested[treatment.vec == 0, ]
  results <- matrix(NA, length(variable), 3)
  p.values <- rep(NA, length(variable))
  for (i in 1:length(variable)) {
    if (variable[i] == treatment) next
    x.t <- treatment.group[, variable[i]]
    x.c <- control.group[, variable[i]]
    n.t <- sum(! is.na(x.t))
    n.c <- sum(! is.na(x.c))
    mean.t <- mean(x.t, na.rm = TRUE)
    mean.c <- mean(x.c, na.rm = TRUE)
    var.t <- var(x.t, na.rm = TRUE)
    var.c <- var(x.c, na.rm = TRUE)
    pooled.sd <- sqrt(((n.t - 1) * var.t + (n.c - 1) * var.c) / (n.t + n.c - 2))
    t.stat <- sqrt(n.t * n.c * (n.t + n.c - 2) / (n.t + n.c)) * (mean.t - mean.c) / 
      sqrt(sum((x.t - mean.t) ^ 2, na.rm = TRUE) + sum((x.c - mean.c) ^ 2, na.rm = TRUE))
    ncp <- (n.t * n.c * epsilon ^ 2) / (n.t + n.c)
    results[i, 1] <- mean.t - mean.c
    results[i, 2] <- (mean.t - mean.c) / pooled.sd
    p.values[i] <- pf(abs(t.stat) ^ 2, 1, n.t + n.c - 2, ncp)
  }
  results[, 3] <- p.adjust(p.values, method = "BH")
  rownames(results) <- variable
  colnames(results) <- c("raw.dif", "std.dif", "p.value")
  results
}

equivalence.F.test.result <- equivarence.test(demand.resp.data, 
                                              c("man", "woman", "R.age", 
                                                "mid.edu", "high.edu", 
                                                "LDP.support", "independent", 
                                                "importance.HOR", "importance.HOC", 
                                                "importance.local"), 
                                              "priming", 0.36)

## Table A.4
round(equivalence.F.test.result, 3)

#### perceived importance of elections ####
## percentage of respondents who considered the HoR election results more important than those of the HoC (note 15)
round(mean(demand.resp.data$prioritize.HOR), 3)

## average perceived importance of the three types of elections (note 27)
round(mean(demand.resp.data$importance.HOR), 2)  # HoR election
round(mean(demand.resp.data$importance.HOC), 2)  # HoC election
round(mean(demand.resp.data$importance.local), 2)  # local elections

# significance test comparing HoR and local elections
t.test(demand.resp.data$importance.HOR, 
       demand.resp.data$importance.local, paired = TRUE)

# significance test comparing local and HoC elections
t.test(demand.resp.data$importance.HOC, 
       demand.resp.data$importance.local, paired = TRUE)

#### AMCEs of all attributes ####
## Figure A.2
AMCE.results <- lm_robust(rating ~ gender + party + age + education + 
                            occupation + hometown + experience + dynasty, 
                          data = demand.data, cluster = rid)
AMCE.results$xlevels$occupation[6] <- "Local politician"
AMCE.results$xlevels$dynasty[2] <- "Local politician"

plot.attr.labels <- c("Gender", "Party Affiliation", "Age", "Education", "Occupation", 
                      "Hometown", "Political experience", "Dynastic status")

cairo_pdf("Figure_A2.pdf", width = 5, height = 6, pointsize = 8)
par(mar = c(3.5, 0, 0.5, 0.5), lwd = 0.5)
plot(NULL, NULL, type = "n", bty = "n", xlim = c(-1.8, 0.5), ylim = c(0, 40), 
     xlab = "", ylab = "", xaxt = "n", yaxt = "n")
abline(v = 0, col = "gray50")
abline(v = c(seq(-1, -0.25, 0.25), 0.25, 0.5), lty = 3, col = "gray50")
x <- 2
y <- 40
for (i in 1:8) {
  text(-1.8, y, plot.attr.labels[i], pos = 4, font = 2)
  text(-1.8, y - 1, 
       paste0("(base: ", tolower(AMCE.results$xlevels[[i]][1]), ")"), pos = 4)
  for (j in 1:(length(AMCE.results$xlevels[[i]]) - 1)) {
    segments(-1.05, y - 1 - j, 0.55, y - 1 - j, col = "gray80")
    text(-1.07, y - 1 - j, AMCE.results$xlevels[[i]][j + 1], pos = 2)
    points(AMCE.results$coefficients[x], y - 1 - j, pch = 19)
    segments(AMCE.results$conf.low[x], y - 1 - j, 
             AMCE.results$conf.high[x], y - 1 - j)
    x <- x + 1
  }
  y <- y - 2 - j
}
axis(1, at = seq(-1, 0.5, 0.25), lwd = 0.5)
mtext("Average marginal component effect", side = 1, at = -0.25, line = 2.5)
dev.off()

#### marginal means of all attributes ####
## Figure A.3
MM.results <- mm(demand.data, 
                 rating ~ gender + party + age + education + 
                   occupation + hometown + experience + dynasty, 
                 ~ rid)

cairo_pdf("Figure_A3.pdf", width = 5, height = 6, pointsize = 8)
par(mar = c(3.5, 0, 0.5, 0.5), lwd = 0.5)
plot(NULL, NULL, type = "n", bty = "n", xlim = c(-1.8, 0.5), ylim = c(0, 40), 
     xlab = "", ylab = "", xaxt = "n", yaxt = "n")
abline(v = seq(-1, 0.5, 0.25), lty = 3, col = "gray50")
x <- 1
y <- 40
for (i in 1:8) {
  text(-1.8, y, plot.attr.labels[i], pos = 4, font = 2)
  for (j in 1:length(AMCE.results$xlevels[[i]])) {
    segments(-1.05, y - j, 0.55, y - j, col = "gray80")
    text(-1.07, y - j, AMCE.results$xlevels[[i]][j], pos = 2)
    points(MM.results$estimate[x] - 4.4, y - j, pch = 19)
    segments(MM.results$lower[x] - 4.4, y - j, 
             MM.results$upper[x] - 4.4, y - j)
    x <- x + 1
  }
  y <- y - 1 - j
}
axis(1, at = seq(-1, 0.5, 0.25), 
     labels = c("3.40", "3.65", "3.90", "4.15", 
                "4.40", "4.65", "4.90"), lwd = 0.5)
mtext("Marginal mean", side = 1, at = 4.05, line = 2.5)
dev.off()

#### main analysis ####
## Figure 2
group.labels <- c("HoR candidates", "HoC candidates", 
                  "HoR candidates for Rs\nwho prioritize the HoR", 
                  "HoC candidates for Rs\nwho prioritize the HoR")
AMCE.wo.prime <- AMCE.w.prime <- list()
AMCE.wo.prime[[1]] <- lm_robust(rating ~ gender + party + age + education + 
                                  occupation + hometown + experience + dynasty, 
                                data = demand.data, 
                                subset = HOC == 0 & priming == 0, 
                                cluster = rid)
AMCE.wo.prime[[2]] <- lm_robust(rating ~ gender + party + age + education + 
                                  occupation + hometown + experience + dynasty, 
                                data = demand.data, 
                                subset = HOC == 1 & priming == 0, 
                                cluster = rid)
AMCE.wo.prime[[3]] <- lm_robust(rating ~ gender + party + age + education + 
                                  occupation + hometown + experience + dynasty, 
                                data = demand.data, 
                                subset = HOC == 0 & priming == 0 & prioritize.HOR == 1, 
                                cluster = rid)
AMCE.wo.prime[[4]] <- lm_robust(rating ~ gender + party + age + education + 
                                  occupation + hometown + experience + dynasty, 
                                data = demand.data, 
                                subset = HOC == 1 & priming == 0 & prioritize.HOR == 1, 
                                cluster = rid)
AMCE.w.prime[[1]] <- lm_robust(rating ~ gender + party + age + education + 
                                 occupation + hometown + experience + dynasty, 
                               data = demand.data, 
                               subset = HOC == 0 & priming == 1, 
                               cluster = rid)
AMCE.w.prime[[2]] <- lm_robust(rating ~ gender + party + age + education + 
                                 occupation + hometown + experience + dynasty, 
                               data = demand.data, 
                               subset = HOC == 1 & priming == 1, 
                               cluster = rid)
AMCE.w.prime[[3]] <- lm_robust(rating ~ gender + party + age + education + 
                                 occupation + hometown + experience + dynasty, 
                               data = demand.data, 
                               subset = HOC == 0 & priming == 1 & prioritize.HOR == 1, 
                               cluster = rid)
AMCE.w.prime[[4]] <- lm_robust(rating ~ gender + party + age + education + 
                                 occupation + hometown + experience + dynasty, 
                               data = demand.data, 
                               subset = HOC == 1 & priming == 1 & prioritize.HOR == 1, 
                               cluster = rid)

diff.wo.prime <- diff.w.prime <- list()
diff.wo.prime[[1]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                  occupation + hometown + experience + dynasty, 
                                data = demand.data, 
                                subset = priming == 0, 
                                cluster = rid)
diff.wo.prime[[2]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                  occupation + hometown + experience + dynasty, 
                                data = demand.data, 
                                subset = priming == 0 & prioritize.HOR == 1, 
                                cluster = rid)
diff.w.prime[[1]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                 occupation + hometown + experience + dynasty, 
                               data = demand.data, 
                               subset = priming == 1, 
                               cluster = rid)
diff.w.prime[[2]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                 occupation + hometown + experience + dynasty, 
                               data = demand.data, 
                               subset = priming == 1 & prioritize.HOR == 1, 
                               cluster = rid)

cairo_pdf("Figure_2.pdf", width = 6, height = 2.5, pointsize = 8)
par(mar = c(3.5, 0, 3, 0), lwd = 0.5)
plot(NULL, NULL, type = "n", bty = "n", xlim = c(-0.65, 1.5), ylim = c(0.5, 5), 
     xlab = "", ylab = "", xaxt = "n", yaxt = "n")
abline(v = c(0, 0.9), col = "gray")
abline(v = c(-0.2, -0.1, 0.1, 0.2, 0.3, 0.7, 0.8, 1, 1.1, 1.2), 
       lty = 3, col = "gray")
adjuster <- 0
for (i in 1:4) {
  segments(AMCE.wo.prime[[i]]$conf.low[2], 5.5 - i - adjuster, 
           AMCE.wo.prime[[i]]$conf.high[2], 5.5 - i - adjuster)
  points(AMCE.wo.prime[[i]]$coefficients[2], 
         5.5 - i - adjuster, pch = 19)
  text(-0.22, 5.5 - i - adjuster, group.labels[i], pos = 2)
  if (i %% 2 == 0) {
    segments(AMCE.wo.prime[[i - 1]]$conf.high[2] + 0.01, 
             6.5 - i - adjuster, 
             max(AMCE.wo.prime[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime[[i]]$conf.high[2]) + 0.03, 
             6.5 - i - adjuster, lwd = 0.25)
    segments(AMCE.wo.prime[[i]]$conf.high[2] + 0.01, 
             5.5 - i - adjuster, 
             max(AMCE.wo.prime[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime[[i]]$conf.high[2]) + 0.03, 
             5.5 - i - adjuster, lwd = 0.25)
    segments(max(AMCE.wo.prime[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime[[i]]$conf.high[2]) + 0.03, 
             6.5 - i - adjuster, 
             max(AMCE.wo.prime[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime[[i]]$conf.high[2]) + 0.03, 
             5.5 - i - adjuster, lwd = 0.25)
    text(max(AMCE.wo.prime[[i - 1]]$conf.high[2], 
             AMCE.wo.prime[[i]]$conf.high[2]) + 0.03, 
         6 - i - adjuster, 
         gsub("-", "\u2212", 
              paste0(sprintf("%4.2f", diff.wo.prime[[i / 2]]$coefficients[28]), " [", 
                     sprintf("%4.2f", diff.wo.prime[[i / 2]]$conf.low[28]), ", ", 
                     sprintf("%4.2f", diff.wo.prime[[i / 2]]$conf.high[28]), "]")), 
         cex = 0.8, pos = 4)
    text(0.65, 5.25 - i - adjuster, 
         paste0("N = ", AMCE.wo.prime[[i]]$nobs / 10), pos = 2, cex = 0.7)
    adjuster <- adjuster + 0.5
  }
}
adjuster <- 0
for (i in 1:4) {
  segments(AMCE.w.prime[[i]]$conf.low[2] + 0.9, 
           5.5 - i - adjuster, 
           AMCE.w.prime[[i]]$conf.high[2] + 0.9, 
           5.5 - i - adjuster)
  points(AMCE.w.prime[[i]]$coefficients[2] + 0.9, 
         5.5 - i - adjuster, pch = 19)
  if (i %% 2 == 0) {
    segments(AMCE.w.prime[[i - 1]]$conf.high[2] + 0.91, 
             6.5 - i - adjuster, 
             max(AMCE.w.prime[[i - 1]]$conf.high[2], 
                 AMCE.w.prime[[i]]$conf.high[2]) + 0.93, 
             6.5 - i - adjuster, lwd = 0.25)
    segments(AMCE.w.prime[[i]]$conf.high[2] + 0.91, 
             5.5 - i - adjuster, 
             max(AMCE.w.prime[[i - 1]]$conf.high[2], 
                 AMCE.w.prime[[i]]$conf.high[2]) + 0.93, 
             5.5 - i - adjuster, lwd = 0.25)
    segments(max(AMCE.w.prime[[i - 1]]$conf.high[2], 
                 AMCE.w.prime[[i]]$conf.high[2]) + 0.93, 
             6.5 - i - adjuster, 
             max(AMCE.w.prime[[i - 1]]$conf.high[2], 
                 AMCE.w.prime[[i]]$conf.high[2]) + 0.93, 
             5.5 - i - adjuster, lwd = 0.25)
    text(max(AMCE.w.prime[[i - 1]]$conf.high[2], 
             AMCE.w.prime[[i]]$conf.high[2]) + 0.93, 
         6 - i - adjuster, 
         gsub("-", "\u2212", 
              paste0(sprintf("%4.2f", diff.w.prime[[i / 2]]$coefficients[28]), " [", 
                     sprintf("%4.2f", diff.w.prime[[i / 2]]$conf.low[28]), ", ", 
                     sprintf("%4.2f", diff.w.prime[[i / 2]]$conf.high[28]), "]")), 
         cex = 0.8, pos = 4)
    text(1.55, 5.25 - i - adjuster, 
         paste0("N = ", AMCE.w.prime[[i]]$nobs / 10), pos = 2, cex = 0.7)
    adjuster <- adjuster + 0.5
  }
}
axis(1, at = seq(-0.2, 0.3, 0.1), 
     labels = c("\u22120.2", "\u22120.1", "0.0", "0.1", "0.2", "0.3"), 
     cex.axis = 0.8, lwd = 0.5)
axis(1, at = seq(0.7, 1.2, 0.1), 
     labels = c("\u22120.2", "\u22120.1", "0.0", "0.1", "0.2", "0.3"), 
     cex.axis = 0.8, lwd = 0.5)
mtext("Without priming", side = 3, at = 0.05, line = 1, cex = 1.2, font = 2)
mtext("With priming", side = 3, at = 0.95, line = 1, cex = 1.2, font = 2)
mtext("Average marginal component effect of candidate gender (woman)", 
      side = 1, at = 0.55, line = 2.5)
dev.off()

#### replication of the main analysis using marginal means ####
## Figure A.4
MM.wo.prime <- MM.w.prime <- list()
for (i in 1:4) {
  MM.wo.prime[[i]] <- MM.w.prime[[i]] <- list()
}
MM.wo.prime[[1]][[1]] <- lm_robust(rating ~ 1, data = demand.data, 
                                   subset = HOC == 0 & priming == 0 & gender == "Male", 
                                   cluster = rid)
MM.wo.prime[[1]][[2]] <- lm_robust(rating ~ 1, data = demand.data, 
                                   subset = HOC == 0 & priming == 0 & gender == "Female", 
                                   cluster = rid)
MM.wo.prime[[2]][[1]] <- lm_robust(rating ~ 1, data = demand.data, 
                                   subset = HOC == 1 & priming == 0 & gender == "Male", 
                                   cluster = rid)
MM.wo.prime[[2]][[2]] <- lm_robust(rating ~ 1, data = demand.data, 
                                   subset = HOC == 1 & priming == 0 & gender == "Female", 
                                   cluster = rid)
MM.wo.prime[[3]][[1]] <- lm_robust(rating ~ 1, data = demand.data, 
                                   subset = HOC == 0 & priming == 0 & 
                                     prioritize.HOR == 1 & gender == "Male", 
                                   cluster = rid)
MM.wo.prime[[3]][[2]] <- lm_robust(rating ~ 1, data = demand.data, 
                                   subset = HOC == 0 & priming == 0 & 
                                     prioritize.HOR == 1 & gender == "Female", 
                                   cluster = rid)
MM.wo.prime[[4]][[1]] <- lm_robust(rating ~ 1, data = demand.data, 
                                   subset = HOC == 1 & priming == 0 & 
                                     prioritize.HOR == 1 & gender == "Male", 
                                   cluster = rid)
MM.wo.prime[[4]][[2]] <- lm_robust(rating ~ 1, data = demand.data, 
                                   subset = HOC == 1 & priming == 0 & 
                                     prioritize.HOR == 1 & gender == "Female", 
                                   cluster = rid)
MM.w.prime[[1]][[1]] <- lm_robust(rating ~ 1, data = demand.data, 
                                  subset = HOC == 0 & priming == 1 & gender == "Male", 
                                  cluster = rid)
MM.w.prime[[1]][[2]] <- lm_robust(rating ~ 1, data = demand.data, 
                                  subset = HOC == 0 & priming == 1 & gender == "Female", 
                                  cluster = rid)
MM.w.prime[[2]][[1]] <- lm_robust(rating ~ 1, data = demand.data, 
                                  subset = HOC == 1 & priming == 1 & gender == "Male", 
                                  cluster = rid)
MM.w.prime[[2]][[2]] <- lm_robust(rating ~ 1, data = demand.data, 
                                  subset = HOC == 1 & priming == 1 & gender == "Female", 
                                  cluster = rid)
MM.w.prime[[3]][[1]] <- lm_robust(rating ~ 1, data = demand.data, 
                                  subset = HOC == 0 & priming == 1 & 
                                    prioritize.HOR == 1 & gender == "Male", 
                                  cluster = rid)
MM.w.prime[[3]][[2]] <- lm_robust(rating ~ 1, data = demand.data, 
                                  subset = HOC == 0 & priming == 1 & 
                                    prioritize.HOR == 1 & gender == "Female", 
                                  cluster = rid)
MM.w.prime[[4]][[1]] <- lm_robust(rating ~ 1, data = demand.data, 
                                  subset = HOC == 1 & priming == 1 & 
                                    prioritize.HOR == 1 & gender == "Male", 
                                  cluster = rid)
MM.w.prime[[4]][[2]] <- lm_robust(rating ~ 1, data = demand.data, 
                                  subset = HOC == 1 & priming == 1 & 
                                    prioritize.HOR == 1 & gender == "Female", 
                                  cluster = rid)

cairo_pdf("Figure_A4.pdf", width = 6, height = 3, pointsize = 9)
par(mar = c(4, 1, 3, 1), lwd = 0.5)
plot(NULL, NULL, type = "n", bty = "n", xlim = c(3.5, 5.35), ylim = c(0.5, 5), 
     xlab = "", ylab = "", xaxt = "n", yaxt = "n")
abline(v = c(seq(4, 4.6, 0.1), seq(4.75, 5.35, 0.1)), lty = 3, col = "gray")
adjuster <- 0
for (i in 1:4) {
  segments(MM.wo.prime[[i]][[1]]$conf.low, 
           5.5 - i - adjuster + 0.1, 
           MM.wo.prime[[i]][[1]]$conf.high, 
           5.5 - i - adjuster + 0.1)
  points(MM.wo.prime[[i]][[1]]$coefficients, 
         5.5 - i - adjuster + 0.1, pch = 19)
  segments(MM.wo.prime[[i]][[2]]$conf.low, 
           5.5 - i - adjuster - 0.1, 
           MM.wo.prime[[i]][[2]]$conf.high, 
           5.5 - i - adjuster - 0.1)
  points(MM.wo.prime[[i]][[2]]$coefficients, 
         5.5 - i - adjuster - 0.1, pch = 21, bg = "white")
  text(3.95, 5.5 - i - adjuster, group.labels[i], pos = 2)
  if (i %% 2 == 0) {
    adjuster <- adjuster + 0.5
  }
}
adjuster <- 0
for (i in 1:4) {
  segments(MM.w.prime[[i]][[1]]$conf.low + 0.75, 
           5.5 - i - adjuster + 0.1, 
           MM.w.prime[[i]][[1]]$conf.high + 0.75, 
           5.5 - i - adjuster + 0.1)
  points(MM.w.prime[[i]][[1]]$coefficients + 0.75, 
         5.5 - i - adjuster + 0.1, pch = 19)
  segments(MM.w.prime[[i]][[2]]$conf.low + 0.75, 
           5.5 - i - adjuster - 0.1, 
           MM.w.prime[[i]][[2]]$conf.high + 0.75, 
           5.5 - i - adjuster - 0.1)
  points(MM.w.prime[[i]][[2]]$coefficients + 0.75, 
         5.5 - i - adjuster - 0.1, pch = 21, bg = "white")
  if (i %% 2 == 0) {
    adjuster <- adjuster + 0.5
  }
}
text(MM.wo.prime[[1]][[1]]$coefficients, 4.6, "Man", pos = 3, cex = 0.8)
text(MM.wo.prime[[1]][[2]]$coefficients, 4.4, "Woman", pos = 1, cex = 0.8)
axis(1, at = seq(4, 4.6, 0.1), cex.axis = 0.9, lwd = 0.5)
axis(1, at = seq(4.75, 5.35, 0.1), 
     labels = c("4.0", "4.1", "4.2", "4.3", "4.4", "4.5", "4.6"), 
     cex.axis = 0.9, lwd = 0.5)
mtext("Without priming", side = 3, at = 4.3, line = 1, cex = 1.2, font = 2)
mtext("With priming", side = 3, at = 5.05, line = 1, cex = 1.2, font = 2)
mtext("Marginal means of candidate gender", 
      side = 1, at = 4.675, line = 3)
dev.off()

#### distribution of the outcome ####
## Figure A.5
histogram.draw <- function(x, pos, adj, d) {
  prop <- prop.table(table(x))
  for (i in 1:8) {
    polygon(c(i - 0.5 + adj, i + 0.5 + adj, i + 0.5 + adj, i - 0.5 + adj), 
            c(pos, pos, pos + d * prop[i], pos + d * prop[i]), 
            col = ifelse(d == -1, "gray", "white"))
  }
}

cairo_pdf("Figure_A5.pdf", width = 6, height = 3, pointsize = 9)
par(mar = c(2.5, 1, 3, 1), lwd = 0.5)
plot(NULL, NULL, type = "n", bty = "n", xlim = c(-6, 18.5), ylim = c(0.5, 5), 
     xlab = "", ylab = "", xaxt = "n", yaxt = "n")
segments(0.4, 4.5, 8.1, 4.5, col = "gray80")
histogram.draw(demand.data$rating[demand.data$HOC == 0 & 
                                    demand.data$priming == 0 & 
                                    demand.data$gender == "Male"], 
               4.5, 0, 1)
histogram.draw(demand.data$rating[demand.data$HOC == 0 & 
                                    demand.data$priming == 0 & 
                                    demand.data$gender == "Female"], 
               4.5, 0, -1)
text(0, 4.5, group.labels[1], pos = 2)
histogram.draw(demand.data$rating[demand.data$HOC == 1 & 
                                    demand.data$priming == 0 & 
                                    demand.data$gender == "Male"], 
               3.5, 0, 1)
histogram.draw(demand.data$rating[demand.data$HOC == 1 & 
                                    demand.data$priming == 0 & 
                                    demand.data$gender == "Female"], 
               3.5, 0, -1)
text(0, 3.5, group.labels[2], pos = 2)
histogram.draw(demand.data$rating[demand.data$HOC == 0 & 
                                    demand.data$priming == 0 & 
                                    demand.data$prioritize.HOR == 1 & 
                                    demand.data$gender == "Male"], 
               2, 0, 1)
histogram.draw(demand.data$rating[demand.data$HOC == 0 & 
                                    demand.data$priming == 0 & 
                                    demand.data$prioritize.HOR == 1 & 
                                    demand.data$gender == "Female"], 
               2, 0, -1)
text(0, 2, group.labels[3], pos = 2)
histogram.draw(demand.data$rating[demand.data$HOC == 1 & 
                                    demand.data$priming == 0 & 
                                    demand.data$prioritize.HOR == 1 & 
                                    demand.data$gender == "Male"], 
               1, 0, 1)
histogram.draw(demand.data$rating[demand.data$HOC == 1 & 
                                    demand.data$priming == 0 & 
                                    demand.data$prioritize.HOR == 1 &  
                                    demand.data$gender == "Female"], 
               1, 0, -1)
text(0, 1, group.labels[4], pos = 2)
histogram.draw(demand.data$rating[demand.data$HOC == 0 & 
                                    demand.data$priming == 1 & 
                                    demand.data$gender == "Male"], 
               4.5, 10, 1)
histogram.draw(demand.data$rating[demand.data$HOC == 0 & 
                                    demand.data$priming == 1 & 
                                    demand.data$gender == "Female"], 
               4.5, 10, -1)
histogram.draw(demand.data$rating[demand.data$HOC == 1 & 
                                    demand.data$priming == 1 & 
                                    demand.data$gender == "Male"], 
               3.5, 10, 1)
histogram.draw(demand.data$rating[demand.data$HOC == 1 & 
                                    demand.data$priming == 1 & 
                                    demand.data$gender == "Female"], 
               3.5, 10, -1)
histogram.draw(demand.data$rating[demand.data$HOC == 0 & 
                                    demand.data$priming == 1 & 
                                    demand.data$prioritize.HOR == 1 & 
                                    demand.data$gender == "Male"], 
               2, 10, 1)
histogram.draw(demand.data$rating[demand.data$HOC == 0 & 
                                    demand.data$priming == 1 & 
                                    demand.data$prioritize.HOR == 1 & 
                                    demand.data$gender == "Female"], 
               2, 10, -1)
histogram.draw(demand.data$rating[demand.data$HOC == 1 & 
                                    demand.data$priming == 1 & 
                                    demand.data$prioritize.HOR == 1 & 
                                    demand.data$gender == "Male"], 
               1, 10, 1)
histogram.draw(demand.data$rating[demand.data$HOC == 1 & 
                                    demand.data$priming == 1 & 
                                    demand.data$prioritize.HOR == 1 &  
                                    demand.data$gender == "Female"], 
               1, 10, -1)
axis(1, at = 1:8, cex.axis = 0.8, lwd = 0.5)
axis(1, at = 11:18, labels = 1:8, cex.axis = 0.8, lwd = 0.5)
mtext("Without priming", side = 3, at = 4.5, line = 1, cex = 1.2, font = 2)
mtext("With priming", side = 3, at = 14.5, line = 1, cex = 1.2, font = 2)
dev.off()

#### interaction term estimates ####
## Table A.5
result.entire <- lm_robust(rating ~ HOC * gender + party + age + education + 
                             occupation + hometown + experience + dynasty, 
                           data = demand.data, cluster = rid)
result.wo.priming <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                 occupation + hometown + experience + dynasty, 
                               data = demand.data, subset = priming == 0, 
                               cluster = rid)
result.w.priming <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                occupation + hometown + experience + dynasty, 
                              data = demand.data, subset = priming == 1, 
                              cluster = rid)
result.not.prioritize <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                     occupation + hometown + experience + dynasty, 
                                   data = demand.data, 
                                   subset = prioritize.HOR == 0, 
                                   cluster = rid)
result.prioritize <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                 occupation + hometown + experience + dynasty, 
                               data = demand.data, 
                               subset = prioritize.HOR == 1, 
                               cluster = rid)
result.wo.priming.not.prioritize <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                                occupation + hometown + experience + dynasty, 
                                              data = demand.data, 
                                              subset = priming == 0 & prioritize.HOR == 0, 
                                              cluster = rid)
result.w.priming.not.prioritize <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                               occupation + hometown + experience + dynasty, 
                                             data = demand.data, 
                                             subset = priming == 1 & prioritize.HOR == 0, 
                                             cluster = rid)
result.wo.priming.prioritize <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                            occupation + hometown + experience + dynasty, 
                                          data = demand.data, 
                                          subset = priming == 0 & prioritize.HOR == 1, 
                                          cluster = rid)
result.w.priming.prioritize <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                           occupation + hometown + experience + dynasty, 
                                         data = demand.data, 
                                         subset = priming == 1 & prioritize.HOR == 1, 
                                         cluster = rid)

cbind(round(rbind(summary(result.entire)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.wo.priming)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.w.priming)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.not.prioritize)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.prioritize)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.wo.priming.not.prioritize)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.w.priming.not.prioritize)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.wo.priming.prioritize)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.w.priming.prioritize)$coefficients["HOC:genderFemale", c(1, 2, 4)]), 3), 
      c(result.entire$nobs, result.wo.priming$nobs, result.w.priming$nobs, 
        result.not.prioritize$nobs, result.prioritize$nobs, 
        result.wo.priming.not.prioritize$nobs, result.w.priming.not.prioritize$nobs, 
        result.wo.priming.prioritize$nobs, result.w.priming.prioritize$nobs))

#### subgroup analysis by respondents' gender ####
## Figure 3
AMCE.wo.prime.men <- AMCE.w.prime.men <- 
  AMCE.wo.prime.women <- AMCE.w.prime.women <- list()
AMCE.wo.prime.men[[1]] <- lm_robust(rating ~ gender + party + age + education + 
                                      occupation + hometown + experience + dynasty, 
                                    data = demand.data, 
                                    subset = HOC == 0 & priming == 0 & R.gender == 1, 
                                    cluster = rid)
AMCE.wo.prime.men[[2]] <- lm_robust(rating ~ gender + party + age + education + 
                                      occupation + hometown + experience + dynasty, 
                                    data = demand.data, 
                                    subset = HOC == 1 & priming == 0 & R.gender == 1, 
                                    cluster = rid)
AMCE.wo.prime.men[[3]] <- lm_robust(rating ~ gender + party + age + education + 
                                      occupation + hometown + experience + dynasty, 
                                    data = demand.data, 
                                    subset = HOC == 0 & priming == 0 & 
                                      prioritize.HOR == 1 & R.gender == 1, 
                                    cluster = rid)
AMCE.wo.prime.men[[4]] <- lm_robust(rating ~ gender + party + age + education + 
                                      occupation + hometown + experience + dynasty, 
                                    data = demand.data, 
                                    subset = HOC == 1 & priming == 0 & 
                                      prioritize.HOR == 1 & R.gender == 1, 
                                    cluster = rid)
AMCE.w.prime.men[[1]] <- lm_robust(rating ~ gender + party + age + education + 
                                     occupation + hometown + experience + dynasty, 
                                   data = demand.data, 
                                   subset = HOC == 0 & priming == 1 & R.gender == 1, 
                                   cluster = rid)
AMCE.w.prime.men[[2]] <- lm_robust(rating ~ gender + party + age + education + 
                                     occupation + hometown + experience + dynasty, 
                                   data = demand.data, 
                                   subset = HOC == 1 & priming == 1 & R.gender == 1, 
                                   cluster = rid)
AMCE.w.prime.men[[3]] <- lm_robust(rating ~ gender + party + age + education + 
                                     occupation + hometown + experience + dynasty, 
                                   data = demand.data, 
                                   subset = HOC == 0 & priming == 1 & 
                                     prioritize.HOR == 1 & R.gender == 1, 
                                   cluster = rid)
AMCE.w.prime.men[[4]] <- lm_robust(rating ~ gender + party + age + education + 
                                     occupation + hometown + experience + dynasty, 
                                   data = demand.data, 
                                   subset = HOC == 1 & priming == 1 & 
                                     prioritize.HOR == 1 & R.gender == 1, 
                                   cluster = rid)
AMCE.wo.prime.women[[1]] <- lm_robust(rating ~ gender + party + age + education + 
                                        occupation + hometown + experience + dynasty, 
                                      data = demand.data, 
                                      subset = HOC == 0 & priming == 0 & R.gender == 2, 
                                      cluster = rid)
AMCE.wo.prime.women[[2]] <- lm_robust(rating ~ gender + party + age + education + 
                                        occupation + hometown + experience + dynasty, 
                                      data = demand.data, 
                                      subset = HOC == 1 & priming == 0 & R.gender == 2, 
                                      cluster = rid)
AMCE.wo.prime.women[[3]] <- lm_robust(rating ~ gender + party + age + education + 
                                        occupation + hometown + experience + dynasty, 
                                      data = demand.data, 
                                      subset = HOC == 0 & priming == 0 & 
                                        prioritize.HOR == 1 & R.gender == 2, 
                                      cluster = rid)
AMCE.wo.prime.women[[4]] <- lm_robust(rating ~ gender + party + age + education + 
                                        occupation + hometown + experience + dynasty, 
                                      data = demand.data, 
                                      subset = HOC == 1 & priming == 0 & 
                                        prioritize.HOR == 1 & R.gender == 2, 
                                      cluster = rid)
AMCE.w.prime.women[[1]] <- lm_robust(rating ~ gender + party + age + education + 
                                       occupation + hometown + experience + dynasty, 
                                     data = demand.data, 
                                     subset = HOC == 0 & priming == 1 & R.gender == 2, 
                                     cluster = rid)
AMCE.w.prime.women[[2]] <- lm_robust(rating ~ gender + party + age + education + 
                                       occupation + hometown + experience + dynasty, 
                                     data = demand.data, 
                                     subset = HOC == 1 & priming == 1 & R.gender == 2, 
                                     cluster = rid)
AMCE.w.prime.women[[3]] <- lm_robust(rating ~ gender + party + age + education + 
                                       occupation + hometown + experience + dynasty, 
                                     data = demand.data, 
                                     subset = HOC == 0 & priming == 1 & 
                                       prioritize.HOR == 1 & R.gender == 2, 
                                     cluster = rid)
AMCE.w.prime.women[[4]] <- lm_robust(rating ~ gender + party + age + education + 
                                       occupation + hometown + experience + dynasty, 
                                     data = demand.data, 
                                     subset = HOC == 1 & priming == 1 & 
                                       prioritize.HOR == 1 & R.gender == 2, 
                                     cluster = rid)

diff.wo.prime.men <- diff.w.prime.men <- 
  diff.wo.prime.women <- diff.w.prime.women <- list()
diff.wo.prime.men[[1]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                      occupation + hometown + experience + dynasty, 
                                    data = demand.data, 
                                    subset = priming == 0 & R.gender == 1, 
                                    cluster = rid)
diff.wo.prime.men[[2]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                      occupation + hometown + experience + dynasty, 
                                    data = demand.data, 
                                    subset = priming == 0 & prioritize.HOR == 1 & R.gender == 1, 
                                    cluster = rid)
diff.w.prime.men[[1]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                     occupation + hometown + experience + dynasty, 
                                   data = demand.data, 
                                   subset = priming == 1 & R.gender == 1, 
                                   cluster = rid)
diff.w.prime.men[[2]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                     occupation + hometown + experience + dynasty, 
                                   data = demand.data, 
                                   subset = priming == 1 & prioritize.HOR == 1 & R.gender == 1, 
                                   cluster = rid)
diff.wo.prime.women[[1]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                        occupation + hometown + experience + dynasty, 
                                      data = demand.data, 
                                      subset = priming == 0 & R.gender == 2, 
                                      cluster = rid)
diff.wo.prime.women[[2]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                        occupation + hometown + experience + dynasty, 
                                      data = demand.data, 
                                      subset = priming == 0 & prioritize.HOR == 1 & R.gender == 2, 
                                      cluster = rid)
diff.w.prime.women[[1]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                       occupation + hometown + experience + dynasty, 
                                     data = demand.data, 
                                     subset = priming == 1 & R.gender == 2, 
                                     cluster = rid)
diff.w.prime.women[[2]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                       occupation + hometown + experience + dynasty, 
                                     data = demand.data, 
                                     subset = priming == 1 & prioritize.HOR == 1 & R.gender == 2, 
                                     cluster = rid)

cairo_pdf("Figure_3a.pdf", width = 6.2, height = 2.5, pointsize = 8)
par(mar = c(3.5, 0, 3, 0), lwd = 0.5)
plot(NULL, NULL, type = "n", bty = "n", xlim = c(-1.2, 2.4), ylim = c(0.5, 5), 
     xlab = "", ylab = "", xaxt = "n", yaxt = "n")
abline(v = c(0, 1.4), col = "gray")
abline(v = c(-0.4, -0.2, 0.2, 0.4, 0.6, 1, 1.2, 1.6, 1.8, 2), 
       lty = 3, col = "gray")
adjuster <- 0
for (i in 1:4) {
  segments(AMCE.wo.prime.men[[i]]$conf.low[2], 5.5 - i - adjuster, 
           AMCE.wo.prime.men[[i]]$conf.high[2], 5.5 - i - adjuster)
  points(AMCE.wo.prime.men[[i]]$coefficients[2], 
         5.5 - i - adjuster, pch = 19)
  text(-0.44, 5.5 - i - adjuster, group.labels[i], pos = 2)
  if (i %% 2 == 0) {
    segments(AMCE.wo.prime.men[[i - 1]]$conf.high[2] + 0.02, 
             6.5 - i - adjuster, 
             max(AMCE.wo.prime.men[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime.men[[i]]$conf.high[2]) + 0.06, 
             6.5 - i - adjuster, lwd = 0.25)
    segments(AMCE.wo.prime.men[[i]]$conf.high[2] + 0.02, 
             5.5 - i - adjuster, 
             max(AMCE.wo.prime.men[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime.men[[i]]$conf.high[2]) + 0.06, 
             5.5 - i - adjuster, lwd = 0.25)
    segments(max(AMCE.wo.prime.men[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime.men[[i]]$conf.high[2]) + 0.06, 
             6.5 - i - adjuster, 
             max(AMCE.wo.prime.men[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime.men[[i]]$conf.high[2]) + 0.06, 
             5.5 - i - adjuster, lwd = 0.25)
    text(max(AMCE.wo.prime.men[[i - 1]]$conf.high[2], 
             AMCE.wo.prime.men[[i]]$conf.high[2]) + 0.06, 
         6 - i - adjuster, 
         gsub("-", "\u2212", 
              paste0(sprintf("%4.2f", diff.wo.prime.men[[i / 2]]$coefficients[28]), " [", 
                     sprintf("%4.2f", diff.wo.prime.men[[i / 2]]$conf.low[28]), ", ", 
                     sprintf("%4.2f", diff.wo.prime.men[[i / 2]]$conf.high[28]), "]")), 
         cex = 0.8, pos = 4)
    text(0.95, 5.25 - i - adjuster, 
         paste0("N = ", AMCE.wo.prime.men[[i]]$nobs / 10), pos = 2, cex = 0.7)
    adjuster <- adjuster + 0.5
  }
}
adjuster <- 0
for (i in 1:4) {
  segments(AMCE.w.prime.men[[i]]$conf.low[2] + 1.4, 
           5.5 - i - adjuster, 
           AMCE.w.prime.men[[i]]$conf.high[2] + 1.4, 
           5.5 - i - adjuster)
  points(AMCE.w.prime.men[[i]]$coefficients[2] + 1.4, 
         5.5 - i - adjuster, pch = 19)
  if (i %% 2 == 0) {
    segments(AMCE.w.prime.men[[i - 1]]$conf.high[2] + 1.42, 
             6.5 - i - adjuster, 
             max(AMCE.w.prime.men[[i - 1]]$conf.high[2], 
                 AMCE.w.prime.men[[i]]$conf.high[2]) + 1.46, 
             6.5 - i - adjuster, lwd = 0.25)
    segments(AMCE.w.prime.men[[i]]$conf.high[2] + 1.42, 
             5.5 - i - adjuster, 
             max(AMCE.w.prime.men[[i - 1]]$conf.high[2], 
                 AMCE.w.prime.men[[i]]$conf.high[2]) + 1.46, 
             5.5 - i - adjuster, lwd = 0.25)
    segments(max(AMCE.w.prime.men[[i - 1]]$conf.high[2], 
                 AMCE.w.prime.men[[i]]$conf.high[2]) + 1.46, 
             6.5 - i - adjuster, 
             max(AMCE.w.prime.men[[i - 1]]$conf.high[2], 
                 AMCE.w.prime.men[[i]]$conf.high[2]) + 1.46, 
             5.5 - i - adjuster, lwd = 0.25)
    text(max(AMCE.w.prime.men[[i - 1]]$conf.high[2], 
             AMCE.w.prime.men[[i]]$conf.high[2]) + 1.46, 
         6 - i - adjuster, 
         gsub("-", "\u2212", 
              paste0(sprintf("%4.2f", diff.w.prime.men[[i / 2]]$coefficients[28]), " [", 
                     sprintf("%4.2f", diff.w.prime.men[[i / 2]]$conf.low[28]), ", ", 
                     sprintf("%4.2f", diff.w.prime.men[[i / 2]]$conf.high[28]), "]")), 
         cex = 0.8, pos = 4)
    text(2.35, 5.25 - i - adjuster, 
         paste0("N = ", AMCE.w.prime.men[[i]]$nobs / 10), pos = 2, cex = 0.7)
    adjuster <- adjuster + 0.5
  }
}
axis(1, at = seq(-0.4, 0.6, 0.2), 
     labels = c("\u22120.4", "\u22120.2", "0.0", "0.2", "0.4", "0.6"), 
     cex.axis = 0.8, lwd = 0.5)
axis(1, at = seq(1, 2, 0.2), 
     labels = c("\u22120.4", "\u22120.2", "0.0", "0.2", "0.4", "0.6"), 
     cex.axis = 0.8, lwd = 0.5)
mtext("Without priming", side = 3, at = 0.1, line = 1, cex = 1.2, font = 2)
mtext("With priming", side = 3, at = 1.5, line = 1, cex = 1.2, font = 2)
mtext("Average marginal component effect of candidate gender (woman)", 
      side = 1, at = 0.8, line = 2.5)
dev.off()

cairo_pdf("Figure_3b.pdf", width = 6.2, height = 2.5, pointsize = 8)
par(mar = c(3.5, 0, 3, 0), lwd = 0.5)
plot(NULL, NULL, type = "n", bty = "n", xlim = c(-1.2, 2.4), ylim = c(0.5, 5), 
     xlab = "", ylab = "", xaxt = "n", yaxt = "n")
abline(v = c(0, 1.4), col = "gray")
abline(v = c(-0.4, -0.2, 0.2, 0.4, 0.6, 1, 1.2, 1.6, 1.8, 2), 
       lty = 3, col = "gray")
adjuster <- 0
for (i in 1:4) {
  segments(AMCE.wo.prime.women[[i]]$conf.low[2], 5.5 - i - adjuster, 
           AMCE.wo.prime.women[[i]]$conf.high[2], 5.5 - i - adjuster)
  points(AMCE.wo.prime.women[[i]]$coefficients[2], 
         5.5 - i - adjuster, pch = 21, bg = "white")
  text(-0.44, 5.5 - i - adjuster, group.labels[i], pos = 2)
  if (i %% 2 == 0) {
    segments(AMCE.wo.prime.women[[i - 1]]$conf.high[2] + 0.02, 
             6.5 - i - adjuster, 
             max(AMCE.wo.prime.women[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime.women[[i]]$conf.high[2]) + 0.06, 
             6.5 - i - adjuster, lwd = 0.25)
    segments(AMCE.wo.prime.women[[i]]$conf.high[2] + 0.02, 
             5.5 - i - adjuster, 
             max(AMCE.wo.prime.women[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime.women[[i]]$conf.high[2]) + 0.06, 
             5.5 - i - adjuster, lwd = 0.25)
    segments(max(AMCE.wo.prime.women[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime.women[[i]]$conf.high[2]) + 0.06, 
             6.5 - i - adjuster, 
             max(AMCE.wo.prime.women[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime.women[[i]]$conf.high[2]) + 0.06, 
             5.5 - i - adjuster, lwd = 0.25)
    text(max(AMCE.wo.prime.women[[i - 1]]$conf.high[2], 
             AMCE.wo.prime.women[[i]]$conf.high[2]) + 0.06, 
         6 - i - adjuster, 
         gsub("-", "\u2212", 
              paste0(sprintf("%4.2f", diff.wo.prime.women[[i / 2]]$coefficients[28]), " [", 
                     sprintf("%4.2f", diff.wo.prime.women[[i / 2]]$conf.low[28]), ", ", 
                     sprintf("%4.2f", diff.wo.prime.women[[i / 2]]$conf.high[28]), "]")), 
         cex = 0.8, pos = 4)
    text(0.95, 5.25 - i - adjuster, 
         paste0("N = ", AMCE.wo.prime.women[[i]]$nobs / 10), pos = 2, cex = 0.7)
    adjuster <- adjuster + 0.5
  }
}
adjuster <- 0
for (i in 1:4) {
  segments(AMCE.w.prime.women[[i]]$conf.low[2] + 1.4, 
           5.5 - i - adjuster, 
           AMCE.w.prime.women[[i]]$conf.high[2] + 1.4, 
           5.5 - i - adjuster)
  points(AMCE.w.prime.women[[i]]$coefficients[2] + 1.4, 
         5.5 - i - adjuster, pch = 21, bg = "white")
  if (i %% 2 == 0) {
    segments(AMCE.w.prime.women[[i - 1]]$conf.high[2] + 1.42, 
             6.5 - i - adjuster, 
             max(AMCE.w.prime.women[[i - 1]]$conf.high[2], 
                 AMCE.w.prime.women[[i]]$conf.high[2]) + 1.46, 
             6.5 - i - adjuster, lwd = 0.25)
    segments(AMCE.w.prime.women[[i]]$conf.high[2] + 1.42, 
             5.5 - i - adjuster, 
             max(AMCE.w.prime.women[[i - 1]]$conf.high[2], 
                 AMCE.w.prime.women[[i]]$conf.high[2]) + 1.46, 
             5.5 - i - adjuster, lwd = 0.25)
    segments(max(AMCE.w.prime.women[[i - 1]]$conf.high[2], 
                 AMCE.w.prime.women[[i]]$conf.high[2]) + 1.46, 
             6.5 - i - adjuster, 
             max(AMCE.w.prime.women[[i - 1]]$conf.high[2], 
                 AMCE.w.prime.women[[i]]$conf.high[2]) + 1.46, 
             5.5 - i - adjuster, lwd = 0.25)
    text(max(AMCE.w.prime.women[[i - 1]]$conf.high[2], 
             AMCE.w.prime.women[[i]]$conf.high[2]) + 1.46, 
         6 - i - adjuster, 
         gsub("-", "\u2212", 
              paste0(sprintf("%4.2f", diff.w.prime.women[[i / 2]]$coefficients[28]), " [", 
                     sprintf("%4.2f", diff.w.prime.women[[i / 2]]$conf.low[28]), ", ", 
                     sprintf("%4.2f", diff.w.prime.women[[i / 2]]$conf.high[28]), "]")), 
         cex = 0.8, pos = 4)
    text(2.35, 5.25 - i - adjuster, 
         paste0("N = ", AMCE.w.prime.women[[i]]$nobs / 10), pos = 2, cex = 0.7)
    adjuster <- adjuster + 0.5
  }
}
axis(1, at = seq(-0.4, 0.6, 0.2), 
     labels = c("\u22120.4", "\u22120.2", "0.0", "0.2", "0.4", "0.6"), 
     cex.axis = 0.8, lwd = 0.5)
axis(1, at = seq(1, 2, 0.2), 
     labels = c("\u22120.4", "\u22120.2", "0.0", "0.2", "0.4", "0.6"), 
     cex.axis = 0.8, lwd = 0.5)
mtext("Without priming", side = 3, at = 0.1, line = 1, cex = 1.2, font = 2)
mtext("With priming", side = 3, at = 1.5, line = 1, cex = 1.2, font = 2)
mtext("Average marginal component effect of candidate gender (woman)", 
      side = 1, at = 0.8, line = 2.5)
dev.off()

#### robustness check using only the first half of tasks ####
first.half.data <- subset(demand.data, task < 11)

## Figure A.6
AMCE.wo.prime.first.half <- AMCE.w.prime.first.half <- list()
AMCE.wo.prime.first.half[[1]] <- lm_robust(rating ~ gender + party + age + education + 
                                             occupation + hometown + experience + dynasty, 
                                           data = first.half.data, 
                                           subset = HOC == 0 & priming == 0, 
                                           cluster = rid)
AMCE.wo.prime.first.half[[2]] <- lm_robust(rating ~ gender + party + age + education + 
                                             occupation + hometown + experience + dynasty, 
                                           data = first.half.data, 
                                           subset = HOC == 1 & priming == 0, 
                                           cluster = rid)
AMCE.wo.prime.first.half[[3]] <- lm_robust(rating ~ gender + party + age + education + 
                                             occupation + hometown + experience + dynasty, 
                                           data = first.half.data, 
                                           subset = HOC == 0 & priming == 0 & prioritize.HOR == 1, 
                                           cluster = rid)
AMCE.wo.prime.first.half[[4]] <- lm_robust(rating ~ gender + party + age + education + 
                                             occupation + hometown + experience + dynasty, 
                                           data = first.half.data, 
                                           subset = HOC == 1 & priming == 0 & prioritize.HOR == 1, 
                                           cluster = rid)
AMCE.w.prime.first.half[[1]] <- lm_robust(rating ~ gender + party + age + education + 
                                            occupation + hometown + experience + dynasty, 
                                          data = first.half.data, 
                                          subset = HOC == 0 & priming == 1, 
                                          cluster = rid)
AMCE.w.prime.first.half[[2]] <- lm_robust(rating ~ gender + party + age + education + 
                                            occupation + hometown + experience + dynasty, 
                                          data = first.half.data, 
                                          subset = HOC == 1 & priming == 1, 
                                          cluster = rid)
AMCE.w.prime.first.half[[3]] <- lm_robust(rating ~ gender + party + age + education + 
                                            occupation + hometown + experience + dynasty, 
                                          data = first.half.data, 
                                          subset = HOC == 0 & priming == 1 & prioritize.HOR == 1, 
                                          cluster = rid)
AMCE.w.prime.first.half[[4]] <- lm_robust(rating ~ gender + party + age + education + 
                                            occupation + hometown + experience + dynasty, 
                                          data = first.half.data, 
                                          subset = HOC == 1 & priming == 1 & prioritize.HOR == 1, 
                                          cluster = rid)

diff.wo.prime.first.half <- diff.w.prime.first.half <- list()
diff.wo.prime.first.half[[1]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                             occupation + hometown + experience + dynasty, 
                                           data = first.half.data, 
                                           subset = priming == 0, 
                                           cluster = rid)
diff.wo.prime.first.half[[2]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                             occupation + hometown + experience + dynasty, 
                                           data = first.half.data, 
                                           subset = priming == 0 & prioritize.HOR == 1, 
                                           cluster = rid)
diff.w.prime.first.half[[1]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                            occupation + hometown + experience + dynasty, 
                                          data = first.half.data, 
                                          subset = priming == 1, 
                                          cluster = rid)
diff.w.prime.first.half[[2]] <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                            occupation + hometown + experience + dynasty, 
                                          data = first.half.data, 
                                          subset = priming == 1 & prioritize.HOR == 1, 
                                          cluster = rid)

cairo_pdf("Figure_A6.pdf", width = 6.2, height = 2.5, pointsize = 8)
par(mar = c(3.5, 0, 3, 0), lwd = 0.5)
plot(NULL, NULL, type = "n", bty = "n", xlim = c(-1.2, 2.4), ylim = c(0.5, 5), 
     xlab = "", ylab = "", xaxt = "n", yaxt = "n")
abline(v = c(0, 1.4), col = "gray")
abline(v = c(-0.4, -0.2, 0.2, 0.4, 0.6, 1, 1.2, 1.6, 1.8, 2), 
       lty = 3, col = "gray")
adjuster <- 0
for (i in 1:4) {
  segments(AMCE.wo.prime.first.half[[i]]$conf.low[2], 5.5 - i - adjuster, 
           AMCE.wo.prime.first.half[[i]]$conf.high[2], 5.5 - i - adjuster)
  points(AMCE.wo.prime.first.half[[i]]$coefficients[2], 
         5.5 - i - adjuster, pch = 19)
  text(-0.44, 5.5 - i - adjuster, group.labels[i], pos = 2)
  if (i %% 2 == 0) {
    segments(AMCE.wo.prime.first.half[[i - 1]]$conf.high[2] + 0.02, 
             6.5 - i - adjuster, 
             max(AMCE.wo.prime.first.half[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime.first.half[[i]]$conf.high[2]) + 0.06, 
             6.5 - i - adjuster, lwd = 0.25)
    segments(AMCE.wo.prime.first.half[[i]]$conf.high[2] + 0.02, 
             5.5 - i - adjuster, 
             max(AMCE.wo.prime.first.half[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime.first.half[[i]]$conf.high[2]) + 0.06, 
             5.5 - i - adjuster, lwd = 0.25)
    segments(max(AMCE.wo.prime.first.half[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime.first.half[[i]]$conf.high[2]) + 0.06, 
             6.5 - i - adjuster, 
             max(AMCE.wo.prime.first.half[[i - 1]]$conf.high[2], 
                 AMCE.wo.prime.first.half[[i]]$conf.high[2]) + 0.06, 
             5.5 - i - adjuster, lwd = 0.25)
    text(max(AMCE.wo.prime.first.half[[i - 1]]$conf.high[2], 
             AMCE.wo.prime.first.half[[i]]$conf.high[2]) + 0.06, 
         6 - i - adjuster, 
         gsub("-", "\u2212", 
              paste0(sprintf("%4.2f", diff.wo.prime.first.half[[i / 2]]$coefficients[28]), " [", 
                     sprintf("%4.2f", diff.wo.prime.first.half[[i / 2]]$conf.low[28]), ", ", 
                     sprintf("%4.2f", diff.wo.prime.first.half[[i / 2]]$conf.high[28]), "]")), 
         cex = 0.8, pos = 4)
    text(0.95, 5.25 - i - adjuster, 
         paste0("N = ", AMCE.wo.prime.first.half[[i]]$nobs / 10), pos = 2, cex = 0.7)
    adjuster <- adjuster + 0.5
  }
}
adjuster <- 0
for (i in 1:4) {
  segments(AMCE.w.prime.first.half[[i]]$conf.low[2] + 1.4, 
           5.5 - i - adjuster, 
           AMCE.w.prime.first.half[[i]]$conf.high[2] + 1.4, 
           5.5 - i - adjuster)
  points(AMCE.w.prime.first.half[[i]]$coefficients[2] + 1.4, 
         5.5 - i - adjuster, pch = 19)
  if (i %% 2 == 0) {
    segments(AMCE.w.prime.first.half[[i - 1]]$conf.high[2] + 1.42, 
             6.5 - i - adjuster, 
             max(AMCE.w.prime.first.half[[i - 1]]$conf.high[2], 
                 AMCE.w.prime.first.half[[i]]$conf.high[2]) + 1.46, 
             6.5 - i - adjuster, lwd = 0.25)
    segments(AMCE.w.prime.first.half[[i]]$conf.high[2] + 1.42, 
             5.5 - i - adjuster, 
             max(AMCE.w.prime.first.half[[i - 1]]$conf.high[2], 
                 AMCE.w.prime.first.half[[i]]$conf.high[2]) + 1.46, 
             5.5 - i - adjuster, lwd = 0.25)
    segments(max(AMCE.w.prime.first.half[[i - 1]]$conf.high[2], 
                 AMCE.w.prime.first.half[[i]]$conf.high[2]) + 1.46, 
             6.5 - i - adjuster, 
             max(AMCE.w.prime.first.half[[i - 1]]$conf.high[2], 
                 AMCE.w.prime.first.half[[i]]$conf.high[2]) + 1.46, 
             5.5 - i - adjuster, lwd = 0.25)
    text(max(AMCE.w.prime.first.half[[i - 1]]$conf.high[2], 
             AMCE.w.prime.first.half[[i]]$conf.high[2]) + 1.46, 
         6 - i - adjuster, 
         gsub("-", "\u2212", 
              paste0(sprintf("%4.2f", diff.w.prime.first.half[[i / 2]]$coefficients[28]), " [", 
                     sprintf("%4.2f", diff.w.prime.first.half[[i / 2]]$conf.low[28]), ", ", 
                     sprintf("%4.2f", diff.w.prime.first.half[[i / 2]]$conf.high[28]), "]")), 
         cex = 0.8, pos = 4)
    text(2.35, 5.25 - i - adjuster, 
         paste0("N = ", AMCE.w.prime.first.half[[i]]$nobs / 10), pos = 2, cex = 0.7)
    adjuster <- adjuster + 0.5
  }
}
axis(1, at = seq(-0.4, 0.6, 0.2), 
     labels = c("\u22120.4", "\u22120.2", "0.0", "0.2", "0.4", "0.6"), 
     cex.axis = 0.8, lwd = 0.5)
axis(1, at = seq(1, 2, 0.2), 
     labels = c("\u22120.4", "\u22120.2", "0.0", "0.2", "0.4", "0.6"), 
     cex.axis = 0.8, lwd = 0.5)
mtext("Without priming", side = 3, at = 0.1, line = 1, cex = 1.2, font = 2)
mtext("With priming", side = 3, at = 1.5, line = 1, cex = 1.2, font = 2)
mtext("Average marginal component effect of candidate gender (woman)", 
      side = 1, at = 0.8, line = 2.5)
dev.off()

## Table A.6
result.entire.first.half <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                        occupation + hometown + experience + dynasty, 
                                      data = first.half.data, cluster = rid)
result.wo.priming.first.half <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                            occupation + hometown + experience + dynasty, 
                                          data = first.half.data, 
                                          subset = priming == 0, 
                                          cluster = rid)
result.w.priming.first.half <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                           occupation + hometown + experience + dynasty, 
                                         data = first.half.data, 
                                         subset = priming == 1, 
                                         cluster = rid)
result.not.prioritize.first.half <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                                occupation + hometown + experience + dynasty, 
                                              data = first.half.data, 
                                              subset = prioritize.HOR == 0, 
                                              cluster = rid)
result.prioritize.first.half <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                            occupation + hometown + experience + dynasty, 
                                          data = first.half.data, 
                                          subset = prioritize.HOR == 1, 
                                          cluster = rid)
result.wo.priming.not.prioritize.first.half <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                                           occupation + hometown + experience + dynasty, 
                                                         data = first.half.data, 
                                                         subset = priming == 0 & prioritize.HOR == 0, 
                                                         cluster = rid)
result.w.priming.not.prioritize.first.half <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                                          occupation + hometown + experience + dynasty, 
                                                        data = first.half.data, 
                                                        subset = priming == 1 & prioritize.HOR == 0, 
                                                        cluster = rid)
result.wo.priming.prioritize.first.half <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                                       occupation + hometown + experience + dynasty, 
                                                     data = first.half.data, 
                                                     subset = priming == 0 & prioritize.HOR == 1, 
                                                     cluster = rid)
result.w.priming.prioritize.first.half <- lm_robust(rating ~ HOC * gender + party + age + education + 
                                                      occupation + hometown + experience + dynasty, 
                                                    data = first.half.data, 
                                                    subset = priming == 1 & prioritize.HOR == 1, 
                                                    cluster = rid)

cbind(round(rbind(summary(result.entire.first.half)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.wo.priming.first.half)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.w.priming.first.half)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.not.prioritize.first.half)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.prioritize.first.half)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.wo.priming.not.prioritize.first.half)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.w.priming.not.prioritize.first.half)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.wo.priming.prioritize.first.half)$coefficients["HOC:genderFemale", c(1, 2, 4)], 
                  summary(result.w.priming.prioritize.first.half)$coefficients["HOC:genderFemale", c(1, 2, 4)]), 3), 
      c(result.entire.first.half$nobs, result.wo.priming.first.half$nobs, 
        result.w.priming.first.half$nobs, result.not.prioritize.first.half$nobs, 
        result.prioritize.first.half$nobs, 
        result.wo.priming.not.prioritize.first.half$nobs, 
        result.w.priming.not.prioritize.first.half$nobs, 
        result.wo.priming.prioritize.first.half$nobs, 
        result.w.priming.prioritize.first.half$nobs))